//// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
//// Jad home page: http://www.kpdus.com/jad.html
//// Decompiler options: packimports(3)
//// Source File Name:   pk1.YCCtbl.java
//
//package pk1;
//
//import java.sql.*;
//
//public class YCC
//{
//
//    public YCC()
//    {
//        try
//        {
//            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//            String dataSourceName = "dbLI";
//            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
//            Connection conli = DriverManager.getConnection(dbURL, "", "");
//            Statement stli1 = conli.createStatement();
//            Statement stli2 = conli.createStatement();
//            Statement stli3 = conli.createStatement();
//            Statement stli4 = conli.createStatement();
//            Statement stli5 = conli.createStatement();
//            Statement stli6 = conli.createStatement();
//            Statement stli7 = conli.createStatement();
//            Statement stli8 = conli.createStatement();
//            Statement stli9 = conli.createStatement();
//            Statement stli10= conli.createStatement();
//            Statement stli11= conli.createStatement();
//            Statement stli12= conli.createStatement();
//
////            String dataSourceName6 = "dbBL";
////            String dbURL6 = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName6).toString();
////            Connection conbk = DriverManager.getConnection(dbURL6, "", "");
////            Statement stbk1 = conbk.createStatement();
////            Statement stbk2 = conbk.createStatement();
////            Statement stbk3 = conbk.createStatement();
//
//            try
//            {
//                stli1.execute("UPDATE tblbcn SET protec_p=null, [protec#]=null, protec_c=null, protec_k=null");
//                stli2.execute("UPDATE tblotn SET protec_p=null, [protec#]=null, protec_c=null, protec_k=null");
//
//                //clean up MASTER files
//                stli3.execute("UPDATE tblbcn SET [protec#]=null");
//                stli4.execute("UPDATE tblbcn SET [protec#]=null");
//
//
//
//                //update Vendor part# on tblbcn master file using PARTLINK #.
//                stli5.execute("UPDATE tblbcn as a INNER JOIN _costycc as b on a.partlink = b.partlink SET [protec#] = b.ycc WHERE a.capa=YES and b.CAPA='y';");
//                stli6.execute("UPDATE tblbcn as a INNER JOIN _costycc as b on a.partlink = b.partlink SET [protec#] = b.ycc WHERE a.capa=NO and b.CAPA=FALSE");
//
//                //update Vendor part# on tblbcn master file using PARTLINK #.
//                stli7.execute("UPDATE tblbcn as a INNER JOIN _costycc as b on a.partlink = b.partlink SET [protec#] = b.ycc WHERE a.capa=YES and b.CAPA='y';");
//                stli8.execute("UPDATE tblbcn as a INNER JOIN _costycc as b on a.partlink = b.partlink SET [protec#] = b.ycc WHERE a.capa=NO and b.CAPA=FALSE;");
//
//
//
//                //update Vendor Pricing using PARTLINK#
//                stli9.execute("UPDATE tblbcn AS a INNER JOIN _costycc AS b ON a.partlink = b.partlink SET a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.capa=YES AND b.CAPA='y';");
//
//                stli10.execute("UPDATE tblbcn AS a INNER JOIN _costycc AS b ON a.partlink = b.partlink SET a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.capa=false AND b.CAPA=FALSE;");
//
//                stli11.execute("UPDATE tblotn AS a INNER JOIN _costycc AS b ON a.partlink = b.partlink SET a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.capa=YES AND b.CAPA='y';");
//
//                stli12.execute("UPDATE tblotn AS a INNER JOIN _costycc AS b ON a.partlink = b.partlink SET a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.capa=false AND b.CAPA=FALSE;");
//
//
//
//
//            }
//            catch(SQLException er)
//            {
//                er.printStackTrace();
//            }
//            stli1.close();
//            stli2.close();
//            stli3.close();
//            stli4.close();
//            stli5.close();
//            stli6.close();
//            stli7.close();
//
////            stbk1.close();
////            stbk2.close();
////            stbk3.close();
////            conli.close();
////            conbk.close();
//        }
//        catch(Exception e)
//        {
//            e.printStackTrace();
//        }
//    }
//}

// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name:   pk1.YCCtbl.java

package MaintMenu.VenPricingUpdTBLN;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class YCCtbl
{

    public YCCtbl(int z)    {  //0 = partlink ; 1 = part#
        int cc=0;
        String dbInternal="";
        String dbExternal="";

        if  (z==0){
            dbInternal="partlink";
            dbExternal="partlink";

        }if (z==1) {
            dbInternal="[part#]";
            dbExternal="prtlnk";
        }

        int counter=1;
        int x=0;
        int y=0;
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection conli = DriverManager.getConnection(dbURL, "", "");

            //Statement stli = conli.createStatement();



//            String dataSourceName6 = "dbBL";
//            String dbURL6 = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName6).toString();
//            Connection conbk = DriverManager.getConnection(dbURL6, "", "");
//            Statement stbk1 = conbk.createStatement();
//            Statement stbk2 = conbk.createStatement();
//            Statement stbk3 = conbk.createStatement();

            //Here is where you enter SQL Statements

            //clean up fields

            String st[] = new String[6];
            st[0] = ("UPDATE tblbcn SET protec_p=null, [protec#]=null, protec_c=null, protec_k=null");
            st[1] =("UPDATE tblotn SET protec_p=null, [protec#]=null, protec_c=null, protec_k=null");

            //clean up MASTER files
//            st[2] =("UPDATE tblbcn SET [protec#]=null");
//            st[3] =("UPDATE tblotn SET [protec#]=null");



//            //update Vendor part# on tblbcn master file using PARTLINK #.
//            st[4] =("UPDATE tblbcn as a INNER JOIN _costycc1 as b on a."+dbInternal+" = b."+dbExternal+" SET   a.[protec#] = b.ycc WHERE a.capa=YES and b.CAPA=YES;");
//            st[5] =("UPDATE tblbcn as a INNER JOIN _costycc1 as b on a."+dbInternal+" = b."+dbExternal+" SET   a.[protec#] = b.ycc WHERE a.capa<>YES and b.CAPA<>YES");
//
//            //update Vendor part# on tblbcn master file using PARTLINK #.
//            st[6] =("UPDATE tblbcn as a INNER JOIN _costycc1 as b on a."+dbInternal+" = b."+dbExternal+" SET   a.[protec#] = b.ycc WHERE a.capa=YES and b.CAPA=YES;");
//            st[7] =("UPDATE tblbcn as a INNER JOIN _costycc1 as b on a."+dbInternal+" = b."+dbExternal+" SET   a.[protec#] = b.ycc WHERE a.CAPA<>YES and b.CAPA<>YES;");
//


            //update Vendor Pricing using PARTLINK#
            st[2] =("UPDATE tblbcn AS a INNER JOIN _costycc1 AS b ON a."+dbInternal+" = b."+dbExternal+" SET   a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.capa = YES AND b.CAPA = YES;");

            st[3] =("UPDATE tblbcn AS a INNER JOIN _costycc1 AS b ON a."+dbInternal+" = b."+dbExternal+" SET   a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.CAPA <> YES AND b.CAPA <> YES;");

//            st[10] =("UPDATE tblbcn AS a INNER JOIN _costycc1 AS b ON a."+dbInternal+" = b."+dbExternal+" SET  a.[protec#] = b.ycc , a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.capa = YES AND b.CAPA = YES;");
//
//            st[11] =("UPDATE tblbcn AS a INNER JOIN _costycc1 AS b ON a."+dbInternal+" = b."+dbExternal+" SET  a.[protec#] = b.ycc , a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.CAPA <> YES AND b.CAPA <> YES;");

//            //update Vendor Pricing using PARTLINK#
//            st[8] =("UPDATE tblbcn AS a INNER JOIN _costycc AS b ON a.partlink = b.partlink SET a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.capa=YES AND b.CAPA=YES;");
//
//            st[9] =("UPDATE tblbcn AS a INNER JOIN _costycc AS b ON a.partlink = b.partlink SET a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.CAPA<>YES AND b.CAPA<>YES;");
//
            st[4] =("UPDATE tblotn AS a INNER JOIN _costycc1 AS b ON a."+dbInternal+" = b."+dbExternal+" SET a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.capa=YES AND b.CAPA=YES;");

            st[5] =("UPDATE tblotn AS a INNER JOIN _costycc1 AS b ON a."+dbInternal+" = b."+dbExternal+" SET a.protec_p = b.price, a.protec_k = b.[pcs/ctn], a.protec_c = b.cuft, a.[protec#] = b.ycc WHERE a.CAPA<>YES AND b.CAPA<>YES;");


//            st[0] = ("UPDATE tblbcn SET gd_p=null, [gd#]=null, gd_c=null, gd_k=null");
//            st[1] = ("UPDATE tblhfn SET gd_p=null, [gd#]=null, gd_c=null, gd_k=null");
//            st[2] = ("UPDATE tblotn SET gd_p=null, [gd#]=null, gd_c=null, gd_k=null");
//
//            //clean up MASTER Category file
//            st[3] = ("UPDATE tblbcn SET gd_no=null");
//            st[4] = ("UPDATE hfmast SET gd_no=null");
//            st[5] = ("UPDATE tblbcn SET gd_no=null");
//
//
//            //update Vendor part# on tblbcn master file using PARTLINK #.
//            st[6] = ("UPDATE tblbcn as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa=YES and b.capa='y';");
//            st[7] = ("UPDATE tblbcn as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.CAPA<>YES and b.capa is null;");
//
//            //update Vendor part# on HFMAST master file using PARTLINK #.
//            st[8] = ("UPDATE hfmast as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa=YES and b.capa='y';");
//            st[9]= ("UPDATE hfmast as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.CAPA<>YES and b.capa is null;");
//
//            //update Vendor part# on tblbcn master file using PARTLINK #.
//            st[10]= ("UPDATE tblbcn as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa=YES and b.capa='y';");
//            st[11]= ("UPDATE tblbcn as a INNER JOIN _costap as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.CAPA<>YES and b.capa is null;");
//
//
//
//
//            //update Vendor Pricing using PARTLINK#
//            st[12]= ("UPDATE tblbcn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.CAPA<>YES AND b.CAPA<>YES;");
//
//            st[13]= ("UPDATE tblbcn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.capa=YES AND b.CAPA='y';");
//
//            st[14]= ("UPDATE tblhfn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.CAPA<>YES AND b.CAPA<>YES;");
//
//            st[15]= ("UPDATE tblhfn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.capa=YES AND b.CAPA='y';");
//
//            st[16]= ("UPDATE tblotn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.CAPA<>YES AND b.CAPA<>YES;");
//
//            st[17]= ("UPDATE tblotn AS a INNER JOIN _costap AS b ON a.partlink = b.prtlnk SET a.gd_p = b.upx, a.[gd#] =b.ap, a.gd_k = b.[std p/k], a.gd_c = b.cuftper WHERE a.capa=YES AND b.CAPA='y';");





            for (x=0; x<st.length;x++){
                Statement stli = conli.createStatement();

                try {
//                    System.out.print(st[x]);
                    int rowsupdated = stli.executeUpdate(st[x]);

                    //System.out.println("TRU : "+rowsupdated+"\t");
                    //JOptionPane.showOptionDialog(null, "Statement : " + st[x] + "\n\nTotal record Updated : " + rowsupdated, "Update Complete", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new Object[]{}, null);

                    cc++;
                    if (cc==4){
                        //System.out.println("");
                        cc=0;
                    }

                }catch(SQLException er) {
                    er.printStackTrace();
                }stli.close();
            }



//            stbk1.close();
//            stbk2.close();
//            stbk3.close();
            conli.close();
//            conbk.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}
